package sg.java.concepts.scjp.collections.comparable;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Collections Sort Example.
 * 
 * <p>
 * This example sorts a list of cars according by brand (String).
 * </p>
 * <p>
 * The car object used itself implements <code>Comparable</code>
 * 
 * @author Oh Chin Boon
 * 
 */
public class CollectionsStringSortApp {
	public static void main(String args[]) {
		List<Car> carList;

		carList = new ArrayList<Car>();

		// add three cars
		carList.add(new Car("Toyota"));
		carList.add(new Car("Maserati"));
		carList.add(new Car("Lexus"));

		// display the state of car list before sort is called
		System.out.println(carList);

		// call sort on the list
		Collections.sort(carList);

		// display the state of car list after sort is called
		System.out.println(carList);

	}
}
